<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Activity extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('activity');
        $table->addColumn('title', 'string')
        ->addColumn('category_id', 'integer')
        ->addColumn('type', 'string', ['comment' => '类别', 'default' => ''])
        ->addColumn('actor', 'string', ['comment' => '明星', 'default' => ''])
        ->addColumn('venues', 'string', ['comment' => '场馆', 'default' => ''])
        ->addColumn('begin_time','datetime', ['comment' => '时间'])
        ->addColumn('fare','decimal', ['default' => 0,'comment' => '票价,0元表示免费'])
        ->addColumn('integral', 'integer', ['default' => 0, 'comment' => '积分兑换，0为不允许积分兑换'])
        ->addColumn('cover', 'string', ['comment' => '海报封面图', 'default' => ''])
        ->addColumn('description', 'text', ['comment' => '内容介绍', 'default' => ''])
        ->addColumn('is_index_top', 'boolean', ['comment' => '是否是首页头条', 'default' => 0])
        ->addColumn('is_index_recommend','boolean', ['comment' => '是否是首页推荐', 'default' => 0])
        ->addColumn('status', 'string', ['comment' => '当前状态', 'default' => '售票中'])
        ->addColumn('author', 'string', ['default' => '', 'comment' => '发布人'])
        ->addColumn('sales', 'integer', ['default' => 0, 'comment' => '售出数量'])
        ->addColumn('created_at', 'datetime')
        ->addColumn('updated_at', 'datetime')
        ->create();
    }
}
